<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>路由管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function viewDetail(id,programName){
			console.info(id);
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneRouter/interfaceList",
				data: {
					ids:id
				},
				<%--data: {id:${"#id"}.val()},--%>
				success: function (subnetList) {
					for (var i = 0; i < subnetList.length; i++) {
						$("#algorithm").append("<li>" + subnetList[i].cidr+'('+subnetList[i].subnetName+')' + "</li>");

					}


				},
				error:function(){
					alert("error");
				}
			});
			$.jBox($("#viewDetailBox").html(), {title:"查看接口", buttons:{"关闭":true}, submit: function(){}});

		}

	</script>
	<script type="text/template" id="viewDetailBox">
		<div>
			<ul id="algorithm">
			</ul>
		</div>
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/scene/sceneRouter/">路由列表</a></li>
		<shiro:hasPermission name="scene:sceneRouter:edit"><li><a href="${ctx}/scene/sceneRouter/form">路由添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="sceneRouter" action="${ctx}/scene/sceneRouter/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>路由名称：</label>
				<form:input path="routerName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>路由状态：</label>
				<form:input path="routerStatus" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>路由名称</th>
				<%--<th>路由状态</th>--%>
				<%--<th>外部网络</th>--%>
				<th>接口列表</th>

				<shiro:hasPermission name="scene:sceneRouter:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sceneRouter">
			<tr>
				<td>
					<a href="${ctx}/scene/sceneRouter/form?id=${sceneRouter.id}">
							${sceneRouter.routerName}
					</a>

				</td>
				<%--<td>--%>
					<%--${sceneRouter.routerStatus}--%>
				<%--</td>--%>
				<%--<td>--%>
						<%--${sceneRouter.networkId}--%>
				<%--</td>--%>
				<td><a href="javascript:viewDetail('${sceneRouter.id}','${sceneRouter.routerName}')" title="查看">查看</a></td>

				<shiro:hasPermission name="scene:sceneRouter:edit"><td>
					<c:choose >
						<c:when test="${empty sceneRouter.networkId}">
							<a href="${ctx}/scene/sceneRouter/form?id=${sceneRouter.id}&type=setGateWay">设置网关</a>
						</c:when>
						<c:otherwise>
							<a href="${ctx}/scene/sceneRouter/removeGateWay?id=${sceneRouter.id}&networkId=${sceneRouter.networkId}" onclick="return confirmx('确认要清除路由(${sceneRouter.routerName})的网关吗？', this.href)">清除网关</a>
						</c:otherwise>
					</c:choose>
					<%--<a href="${ctx}/scene/sceneRouter/addInterface?id=${sceneRouter.id}">增加接口</a>--%>
					<a href="${ctx}/scene/sceneRouter/interfaceManage?id=${sceneRouter.id}">接口管理</a>
					<%--<a href="${ctx}/scene/sceneRouter/form?id=${sceneRouter.id}&type=copy">复制</a>--%>
					<a href="${ctx}/scene/sceneRouter/form?id=${sceneRouter.id}&type=update">修改</a>
					<a href="${ctx}/scene/sceneRouter/delete?id=${sceneRouter.id}" onclick="return confirmx('确认要删除该路由吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>